#ifndef FORGETDIALOG_H
#define FORGETDIALOG_H
#include <QDialog>
#include <QMap>
#include <QTimer>
#include "global.h"
namespace Ui {
class ForgetDialog;
}

class ForgetDialog : public QDialog
{
    Q_OBJECT

public:
    explicit ForgetDialog(QWidget *parent = nullptr, unsigned short counter = 15);
    ~ForgetDialog();
signals:
    void sigSwitchLogin();

private slots:
    void on_btn_verify_clicked();
    void slot_reset_mod_finish(ReqId id, QString res, ErrorCode ec);
    void on_forget_btn_ok_clicked();
    void on_forget_btn_back_clicked();

private:
    QMap<ReqId, std::function<void(const QJsonObject &)>> _handlers;
    Ui::ForgetDialog *ui;
    QMap<TipErr, QString> _tip_errs;
    QTimer _timer;
    unsigned short _counter;

private:
    void initHttpHandlers();
    bool CheckUserValid();
    bool CheckEmailValid();
    bool CheckPassWordValid();
    bool CheckVerifyValid();
    void AddTipErr(TipErr te, QString tips);
    void DelTipErr(TipErr te);
    void showTip(const QString &err_str, bool success = false);
};

#endif // FORGETDIALOG_H
